<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        span {
            display: inline-block;
            line-height: 30px;
            font-size: 30px;
            width: 30px;
            height: 30px;
        }
    </style>
</head>
<body>
    <script>
        // 菱形
        for (var i = 1; i <= 9; i++) {
            for (var k = i; k < 9; k++) {
                document.write("<span></span>")
            }
            for (var j = 1; j <= i + i - 1; j++) {
                document.write("<span>※</span>")
            }
            document.write("<br>")
        }
        for (var i = 1; i < 9; i++) {
            for (var k = 1; k <= i; k++) {
                document.write("<span></span>")
            }
            for (var j = i + i - 1; j < 16; j++) {
                document.write("<span>※</span>")
            }
            document.write("<br>")
        }
        //输入两个数,得出最大公约数
        function gys(a,b) {
            var min = a > b ? b : a;
            for(var i = min;i >= 1;i--){
                if(a % i === 0 && b % i === 0){
                    return i;
                }
            }   
        }
        var res1 = gys(+prompt("第一个数"),+prompt("第二个数"));
        alert("最大公约数" + res1);

        //封装一个函数,对一个四位数加密
        function jm(num){
            var num1 = (parseInt(num / 1000) + 5) % 8 * 10;
            var num2 = (parseInt(num / 100) % 10 + 5) % 8;
            var num3 = (parseInt(num / 10) % 10 + 5) % 8 * 1000;
            var num4 = (num % 10 + 5) % 8 * 100;
            var sum = num1 + num2 + num3 +num4
            return sum
        }
        var res2 = jm(5678);
        console.log(res2);

        //100-999的水仙花
        for(var i = 100;i <= 999;i++){
            var num1 = parseInt(i / 100 % 10) **3;
            var num2 = parseInt(i / 10 % 10) **3;
            var num3 = (i % 10) **3;
            if(i === num1 + num2 + num3){
                console.log(i + "是水仙花数");
            }
        }
    </script>
</body>
</html>